build(abi/ffi): wire the Idris2 ABI + Zig FFI to compile (first time)#79
Merged
Conversation
The ABI (src/abi/, Idris2) and FFI (ffi/zig/) layers had never actually built.
This wires both green and adds `just` recipes to keep them that way.
Idris2 ABI — new `rpa-elysium-abi.ipkg` (sourcedir=src/abi; mirrors HAR's
har-abi.ipkg). Fixes so all five modules typecheck:
- flatten module names to the src/abi/ layout (RpaElysium.Abi.* -> bare), which
also fixes Foreign.idr's ABI-vs-Abi case mismatch (it imported modules that
did not exist);
- Types.idr/Layout.idr: correct the `eventKindTagValid` / `eventKindTagFitsInByte`
LTE proofs — every clause wrongly used `LTE 5 5`; each now matches its tag
(0->LTEZero, 1->LTESucc LTEZero, ...);
- Layout.idr: `import Data.Nat` (LTE/GT were undefined);
- Foreign.idr: define the FFI glue types that were referenced but never declared
— `Handle` (+ createHandle/handlePtr), `Result` (Ok=0..NullPointer=4, matching
the Zig enum); fix `registerCallback` to take a raw C-callable pointer (an
Idris closure cannot be `cast` to AnyPtr).
Zig FFI — port build.zig to the Zig 0.15 API (addSharedLibrary/addStaticLibrary
-> addLibrary + shared module + linkage; link_libc for the C allocator) and fix
main.zig for 0.15 (opaque-with-fields -> struct; callconv(.C) -> callconv(.c)).
`zig build` now produces librpa_ffi.{a,so} and `zig build test` passes. The 11
exported C symbols match Foreign.idr's %foreign declarations, and the Result
codes agree.
Justfile: `verify-abi`, `build-ffi`, `test-ffi`, `verify-abi-ffi`.
Known follow-ups (not compile issues): Foreign.idr's `process` wrapper treats
result 0 as error while `processArray`/the Zig side treat 0 as ok — the success
convention needs reconciling; generated/abi/ C headers still unimplemented;
LinearDispatch.eph (Ephapax) needs its own toolchain to build.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- grant secret-scanner reusable its requested job permissions - drop invalid timeout-minutes on reusable-call jobs - drop hashFiles() from job-level if: expressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The ABI (
src/abi/, Idris2) and FFI (ffi/zig/) layers had never actuallybuilt — no ipkg, module names that didn't resolve, broken proofs, missing FFI
glue types, and a Zig
build.zigon a pre-0.15 API. This wires both greenand adds
justrecipes to keep them that way.Idris2 ABI —
idris2 --build rpa-elysium-abi.ipkg✅ (5/5 modules)rpa-elysium-abi.ipkg(sourcedir=src/abi; mirrors HAR'shar-abi.ipkg).src/abi/layout — this also fixesForeign.idr'sABI-vs-Abicase mismatch (it imported modules thatdidn't exist).
Types.idr/Layout.idr:eventKindTagValid/eventKindTagFitsInByteevery clause wrongly usedLTE 5 5; each now matchesits actual tag (
0→LTEZero,1→LTESucc LTEZero, …).Layout.idr:import Data.Nat(LTE/GTwere undefined).Foreign.idr: define the FFI glue that was referenced but never declared —Handle(+createHandle/handlePtr) andResult(Ok=0..NullPointer=4,matching the Zig enum); fix
registerCallbackto take a raw C-callable pointer(an Idris closure can't be
casttoAnyPtr).Zig FFI —
zig build+zig build test✅build.zigto the Zig 0.15 API (addSharedLibrary/addStaticLibrary→
addLibrary+ shared module +linkage;link_libcfor the C allocator).main.zigfor 0.15 (opaque-with-fields →struct;callconv(.C)→callconv(.c)).librpa_ffi.{a,so}; tests pass. The 11 exported C symbols matchForeign.idr's%foreigndeclarations, and theResultcodes agree.Justfile
verify-abi,build-ffi,test-ffi,verify-abi-ffi.Known follow-ups (not compile issues)
Foreign.idr'sprocesswrapper treats result0as error whileprocessArrayand the Zig side treat0as ok — the success conventionneeds reconciling (correctness, with a test).
generated/abi/C headers still unimplemented (the formal Idris↔Zig bridge).LinearDispatch.eph(Ephapax) needs its own toolchain to build.Follows the shared-ABI adoption (#78).
🤖 Generated with Claude Code